local qingwu = fk.CreateSkill {
  name = "lingling__qingwu",
}

Fk:loadTranslationTable{
  ["lingling__qingwu"] = "卿舞",
  [":lingling__qingwu"] = "当你受到伤害后或脱离濒死状态后，你可以摸X张牌（X为有【杀】的角色数，至少为1至多为3）。",
}

local spec = {
  anim_type = "masochism",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(qingwu.name) and not player.dead
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local n = #table.filter(room.alive_players, function (p)
      return table.find(p:getCardIds("h"), function (id)
        return Fk:getCardById(id).trueName == "slash"
      end)
    end)
    n = math.max(n, 1)
    n = math.min(n, 3)
    player:drawCards(n, qingwu.name)
  end,
}

qingwu:addEffect(fk.Damaged, spec)
qingwu:addEffect(fk.AfterDying, spec)

return qingwu
